const express = require('express')
const router = express.Router()
const path = '/userTel'
const service = require('../service/userTelService')

router.get('/', function (req, res) {
  res.send('Hello World-userTel')
})

router.get('/queryAll', async (req, res) => {
  const data = await service.queryAll()
  res.json(data)
})

router.get('/queryTask', async (req, res) => {
  const data = await service.queryTask()
  res.json(data)
})

// 接收json参数
/**
 * json对象参数
 * @route POST /demo/helloJson
 * @group demo
 * @param {User.model} user.body.required - 用户,注意body
 * @returns {User.model} 200 - 用户信息
 * @returns {Error.model}  500 - 错误信息
 */
router.post('/queryByPage', async (req, res) => {
  console.log('req.currentPage===' + req.body.currentPage)
  console.log('req.pageSize===' + req.body.pageSize)
  const data = await service.queryTask(req.body)
  res.json(data)
})

module.exports = (app) => {
  app.use(path, router)
}
